#include <iostream>
#include <string>
using namespace std;

class Product 
{
public:
	virtual ~Product() {}
	virtual void perform() = 0;
};

class ProductA: public Product 
{
public:
	void perform() 
	{
		cout << "create the product A" << endl;
	}
};

class ProductB: public Product 
{
public:
	void perform() 
	{
		cout << "create the product B" << endl;
	}
};

class ProductC: public Product 
{
public:
	void perform() 
	{
		cout << "create the product C" << endl;
	}
};

class Factory 
{
public:
	static Factory* getInstance() 
	{
		static Factory* instance;
		if(instance == NULL) instance = new Factory();
		return instance;
	}
	Product* create(int type) 
	{
		switch (type) 
		{
			case 1:
				return new ProductA();
			case 2:
				return new ProductB();
			case 3:
				return new ProductC();
		}
		return NULL;
	}
private:
	Factory();
};

int main() 
{
	Factory* factory = Factory::getInstance();
	int type = 1;
	Product* product = factory->create(type);
	product->perform();
	return 0;
}
